package com.haoan.index.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.haoan.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.haoan.common.annotation.Log;
import com.haoan.common.core.controller.BaseController;
import com.haoan.common.core.domain.AjaxResult;
import com.haoan.common.enums.BusinessType;
import com.haoan.index.domain.AnnualPlace;
import com.haoan.index.service.AnnualPlaceService;
import com.haoan.common.utils.poi.ExcelUtil;
import com.haoan.common.core.page.TableDataInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 年卡下景区列Controller
 *
 * @author autoGen
 * @date 2025-01-03
 */
@Api(value="年卡下景区列",tags = "年卡下景区列")
@RestController
@RequestMapping("/index/annualPlace")
public class AnnualPlaceController extends BaseController
{
    @Resource
    private AnnualPlaceService annualPlaceService;

    /**
     * 查询年卡下景区列列表
     */
    @ApiOperation("查询年卡下景区列列表")
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(AnnualPlace annualPlace)
    {
        startPage();
        List<AnnualPlace> list = annualPlaceService.selectAnnualPlaceList(annualPlace);
        return getDataTable(list);
    }

    /**
     * 导出年卡下景区列列表
     */
    @ApiOperation("导出年卡下景区列列表")
    @PreAuthorize("@ss.hasPermi('index:annualPlace:export')")
    @Log(title = "年卡下景区列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AnnualPlace annualPlace)
    {
        List<AnnualPlace> list = annualPlaceService.selectAnnualPlaceList(annualPlace);
        ExcelUtil<AnnualPlace> util = new ExcelUtil<AnnualPlace>(AnnualPlace.class);
        util.exportExcel(response, list, "年卡下景区列数据");
    }

    /**
     * 获取年卡下景区列详细信息
     */
    @ApiOperation("获取年卡下景区列详细信息")
    @Anonymous
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(annualPlaceService.selectAnnualPlaceById(id));
    }

    /**
     * 新增年卡下景区列
     */
    @ApiOperation("新增年卡下景区列")
    @PreAuthorize("@ss.hasPermi('index:annualPlace:add')")
    @Log(title = "年卡下景区列", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AnnualPlace annualPlace)
    {
        return toAjax(annualPlaceService.insertAnnualPlace(annualPlace));
    }

    /**
     * 修改年卡下景区列
     */
    @ApiOperation("修改年卡下景区列")
    @PreAuthorize("@ss.hasPermi('index:annualPlace:edit')")
    @Log(title = "年卡下景区列", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AnnualPlace annualPlace)
    {
        return toAjax(annualPlaceService.updateAnnualPlace(annualPlace));
    }

    /**
     * 删除年卡下景区列
     */
    @ApiOperation("删除年卡下景区列")
    @PreAuthorize("@ss.hasPermi('index:annualPlace:remove')")
    @Log(title = "年卡下景区列", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(annualPlaceService.deleteAnnualPlaceByIds(ids));
    }
}
